<?php
        $xcrud = Xcrud::get_instance();
        $xcrud->table('news');
        $xcrud->relation('category','news_category','cat_id','cat_title');
        $xcrud->relation('subcategory', 'news_subcategory', 'sub_id', 'sub_title', null, null, null, null, null, 'category','category');
        

      
      //------- GRIDVIEW MODE ---------
      
        //Hide field in gridview
        $xcrud->columns('id,tieude,category,subcategory,user_add,date_add,home,home2,sticky,hilight,tinhtrang', false);
              
        //Change type to remote image -------
       $xcrud->change_type('hinhanh', 'remote_image');
         $xcrud->change_type('keyword', 'text');
	   $xcrud->change_type('gioithieu', 'text');
	   	   $xcrud->change_type('tags', 'text');
		   $xcrud->change_type('hilight_description,description', 'textarea');
  
                  $xcrud->fields('tieude,tags,tinhtrang,category,subcategory,hinhanh', false, 'Infor');
                  $xcrud->fields('gioithieu,noidung', false, 'ConTent');
				  $xcrud->fields('seo_tieude,seo_title,keyword,description', false, 'SEO');
				   $xcrud->fields('hilight,hilight_title,hilight_description,hilight_image', false, 'Hilight');
                  $xcrud->fields('home,home2,sticky', false, 'Sticky');
                
                //Pass data and don't show on form'
                  $xcrud->pass_var(array("user_add"=>$_SESSION['username'],
										  "date_add"=>date('Y-m-d'),
										  "time_show"=>date('D, d M y H:i A'),
										  "capnhat_time"=>date('Y-m-d H:i:s')),'create');
     
                  $xcrud->pass_var(array("capnhat_user"=>$_SESSION['username'],
							  "capnhat_time"=>date('Y-m-d H:i:s'),
                              "time_update"=>date('D, d M y H:i A')),'edit');
      
      //----------VIEW MODE-----------
      // Display field in view mode
        //          $xcrud->fields('username,email,avatar,level,danhhieu,chuky,register_day,last_login', false, 'Personal','view');
       //           $xcrud->fields('moderator,manga,mangaupload,status,ip', false, 'Private','view');
              
      
                $xcrud->label(array('tieude'=>'Tiêu Đề','seo_tieude'=>'Alias','tinhtrang'=>'Tình Trạng','category'=>'Danh Mục','subcategory'=>'Danh Mục Con','hinhanh'=>'Hình Ảnh','gioithieu'=>'Giới  Thiệu','noidung'=>'Nội Dung','user_add'=>'User','date_add'=>'Ngày','time_show'=>'Time Show','capnhat_time'=>'Update Time','capnhat_user'=>'Update User','time_update'=>'Update Time Show','solanxem'=>'Views','comment_num'=>'Comment','home'=>'Home','home2'=>'Home 2'));
                 $xcrud->theme('bootstrap');
				 
				 
				// $xcrud->before_insert('', 'seotag', 'function.php');
				 $xcrud->before_insert('', 'handle', 'function.php');
				 $xcrud->before_update('', 'seotag', 'function.php');
                 $xcrud->table_name('News Manage System');
				 $xcrud->show_primary_ai_column(true);
				 
				 
				 if($_SESSION['per']==2){
					   $xcrud->unset_remove();
				 }
				  if($_SESSION['per']==3){
					   exit();
				 }
				 
        //         $xcrud->unset_add();
                 $xcrud->unset_csv();
                $xcrud->unset_print();
                        
                 echo $xcrud->render();
            
                //PHAI VALID LAI, CHI CO MOT VAI USER MOI CO QUYEN SUA THONG TIN CUA ADMIN GROUP VA CHINH GROUP CUA MEMBER
                //EMAIL VA  TAI KHOAN CUA USER KHONG THE THAY DOI 

?>
